﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PreguntaAlExperto.RulesLayer.Entities
{
    public class Article : PreguntaAlExperto.RulesLayer.Base.BaseEntities
    {
        public int Article_ID
        {
            get;
            set;
        }

        public int Publisher_ID
        {
            get;
            set;
        }

        public Publisher PublisherEntity
        {
            get;
            set;
        }

        public string Path
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public string Short_Description
        {
            get;
            set;
        }

        public DateTime Publish_Date
        {
            get;
            set;
        }

        public bool AllowedToPublish
        {
            get;
            set;
        }

        public int TotalVisits
        {
            get;
            set;
        }

        public int TotalPoints
        {
            get;
            set;
        }

        public int TotalVotes
        {
            get;
            set;
        }

        public string Guid
        {
            get
            {
                string guid = System.Guid.Empty.ToString();
                string id = Article_ID.ToString();
                return guid.Substring(0, guid.Length - id.Length) + id;
            }
        }

        private List<Pair> languages;
        public List<Pair> Languages
        {
            get
            { 
                if(languages == null) 
                    languages = new List<Pair>();

                return languages; 
            }
            set
            {
                languages = value;
            }
        }

        private List<Pair> technologies;
        public List<Pair> Technologies
        {
            get
            {
                if (technologies == null)
                    technologies = new List<Pair>();

                return technologies;
            }
            set
            {
                technologies = value;
            }
        }

        private List<Pair> skills;
        public List<Pair> Skills
        {
            get
            {
                if (skills == null)
                    skills = new List<Pair>();

                return skills;
            }
            set
            {
                skills = value;
            }
        }

        private List<Pair> platforms;
        public List<Pair> Platforms
        {
            get
            {
                if (platforms == null)
                    platforms = new List<Pair>();

                return platforms;
            }
            set
            {
                platforms = value;
            }
        }

        public List<Pair> Tags
        {
            get;
            set;
        }

        public String[] AllCategories
        {
            get
            {

                System.Collections.Generic.List<string> categories =
                    new System.Collections.Generic.List<string>();

                foreach (PreguntaAlExperto.RulesLayer.Entities.Pair p in Platforms)
                {
                    categories.Add(p.Name);
                }

                foreach (PreguntaAlExperto.RulesLayer.Entities.Pair p in Languages)
                {
                    categories.Add(p.Name);
                }

                foreach (PreguntaAlExperto.RulesLayer.Entities.Pair p in Skills)
                {
                    categories.Add(p.Name);
                }

                foreach (PreguntaAlExperto.RulesLayer.Entities.Pair p in Technologies)
                {
                    categories.Add(p.Name);
                }

                return categories.ToArray();
            }
        }

        public int Group_ID
        {
            get;
            set;
        }

    }
}
